package com.woniu.controller;

import com.woniu.entity.Result;
import com.woniu.pojo.DoctorLabel;
import com.woniu.service.IDoctorLabelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author doujiao
 * @since 2022-10-12
 */
@RestController
@RequestMapping("/doctorLabel")
@Api(tags = "医生标签模块")
public class DoctorLabelController extends BaseController{

    @Resource
    private IDoctorLabelService doctorLabelService;
    /**
     * 查所有
     */
    @GetMapping
    @ApiOperation("查所有")
    public Result queryAll(){
        List<DoctorLabel> list = doctorLabelService.list();
        System.out.println(list);
        return toDataResult(list);
    }
    /**
     * 根据id查询
     */
    @GetMapping("/{id}")
    public Result queryById(@PathVariable Long id){
        DoctorLabel doctorLabel = doctorLabelService.getById(id);
        return toDataResult(doctorLabel);
    }

    /**
     * 增加
     */
    @PostMapping
    @ApiOperation("增加一条")
    public Result add(@RequestBody DoctorLabel doctorLabel){
        boolean save = doctorLabelService.save(doctorLabel);
        return toResult(save);
    }
    /**
     * 编辑
     */
    @PutMapping
    @ApiOperation("编辑一条")
    public Result edit(@RequestBody DoctorLabel doctorLabel){
        boolean result = doctorLabelService.updateById(doctorLabel);
        return toResult(result);
    }
    /**
     * 根据id删除
     */
    @DeleteMapping("/{id}")
    @ApiOperation("根据id删除")
    public Result removeById(@PathVariable Long id){
        boolean result = doctorLabelService.removeById(id);
        return toResult(result);
    }
}
